﻿using CppAst;

namespace ast;

public class FunctionInfo : IComparer<FunctionInfo>, IComparable<FunctionInfo>
{
    public ClassInfo? ClassInfo;
    public List<ExportPara> ExportParameters = new();
    public ExportType ExportReturnType  ;
    public CppFunction Function;
    public ModuleInfo ModuleInfo;
    public FileInfo FileInfo;

    public FunctionInfo(CppFunction function, ModuleInfo moduleInfo, ClassInfo? classInfo, FileInfo fileInfo)
    {
        Function = function;
        ModuleInfo = moduleInfo;
        ClassInfo = classInfo;
        FileInfo = fileInfo;
    }

    public int Compare(FunctionInfo x, FunctionInfo y)
    {
        if (ReferenceEquals(x, y))
        {
            return 0;
        }

        if (ReferenceEquals(null, y))
        {
            return 1;
        }

        if (ReferenceEquals(null, x))
        {
            return -1;
        }

        return string.Compare(x.ToString(), y.ToString(), StringComparison.Ordinal);
    }

    public int CompareTo(FunctionInfo? other)
    {
        return Compare(this, other);
    }
}